package com.zeny.express.framework.mq;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Father extends Man {
	private List<Son> sonList = new ArrayList<Son>();
	private Set<Son> sonSet = new HashSet<Son>();
	private Map<String, Son> sonMap = new HashMap<String, Son>();

	public void addSon(Son son) {
		// son.setFather(this);
		sonList.add(son);
		sonSet.add(son);
		sonMap.put(son.getName(), son);
	}

	public List<Son> getSonList() {
		return sonList;
	}

	public void setSonList(List<Son> sonList) {
		this.sonList = sonList;
	}

	public Set<Son> getSonSet() {
		return sonSet;
	}

	public void setSonSet(Set<Son> sonSet) {
		this.sonSet = sonSet;
	}

	public Map<String, Son> getSonMap() {
		return sonMap;
	}

	public void setSonMap(Map<String, Son> sonMap) {
		this.sonMap = sonMap;
	}

	public boolean equals(Father otherFather) {
		if (!super.equals(otherFather)) {
			return false;
		}

		if (this.getSonList().size() != otherFather.getSonList().size()) {
			return false;
		}

		for (int i = 0; i < this.getSonList().size(); i++) {
			Son son = this.getSonList().get(i);
			Son otherSon = otherFather.getSonList().get(i);

			if (!son.equals(otherSon)) {
				return false;
			}
		}

		if (this.getSonSet().size() != otherFather.getSonSet().size()) {
			return false;
		}

		// for(Son son : sonSet)
		// {
		// if(!otherFather.getSonSet().contains(son))
		// {
		// return false;
		// }
		// }

		if (this.getSonMap().size() != otherFather.getSonMap().size()) {
			return false;
		}

		// for(Son son : sonMap.values())
		// {
		// if(!otherFather.getSonMap().containsValue(son))
		// {
		// return false;
		// }
		// }

		return true;
	}
}
